<template>
	<view>
		<uni-nav-bar dark :fixed="true" shadow background-color="#00aaff" status-bar left-icon="left" title="交易详情" @clickLeft="back"/>
		<uni-card :title="trade_info.account_name" :sub-title="trade_info.account_no" v-if="trade_info !== ''">
			<view class="card-body">
				<view> 交易流水：<text style="font-size:22rpx">{{trade_info.serial_no}}</text> </view>
				<view> 交易金额：<text style="color:red">￥ {{trade_info.trans_amount}}</text> </view>
				<view> 交易总额：<text style="color:red">￥ {{trade_info.total_amount}}</text> </view>
				<view> 手续费用：<text style="color:red">￥ {{trade_info.trans_fee}}</text> </view>
				<view> 收款户名：<text style="font-size:24rpx">{{trade_info.opp_account_name}}</text> </view>
				<view> 收款卡号：<text style="font-size:24rpx">{{trade_info.opp_account_no}}</text> </view>
				<view> 操作摘要：<text style="font-size:24rpx">{{trade_info.remark}}</text> </view>
			</view>
		</uni-card>
		<!-- <view style="padding:0 40rpx;"> -->
			<!-- <button type="primary" @click="getReturnBill">回单下载</button> -->
		<!-- </view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				serial_date: "",
				serial_no: "",
				account_no: "",
				trade_info: ''
			}
		},
		
		onLoad(options) {
			let {account_no,original_serialno,serial_date} = options
			
			if(!account_no || !original_serialno || !serial_date) {
				uni.navigateBack()
			} else {
				this.serial_date = this.$moment(serial_date).format('YYYY-MM-DD')
				this.serial_no = original_serialno
				this.account_no = account_no
				
				this.getTradeDetail()
			}
		},
		
		onShow() {
			let uid = uni.getStorageSync('uid');
			
			if(!uid || uid == "") {
				uni.navigateTo({
					url: '/pages/login/index'
				})
			}
		},
		
		methods: {
			back() {
				uni.navigateTo({
					url: '/pages/trade/index'
				})
			},
			
			getTradeDetail() {
				uni.showLoading({
					title:'加载中'
				})
				uni.request({
					url: '/trade/getTradeDetail',
					data: {
						account_no: this.account_no,
						serial_date: this.serial_date,
						original_serialno: this.serial_no
					},
					success: (res) => {
						if(res.data.success) {
							this.trade_info = res.data.data
						} else {
							uni.showToast({
								icon: 'error',
								title: res.data.errMessage
							})
						}
					},
					complete: () => {
						uni.hideLoading()
					}
				})
			},
			
			getReturnBill() {
				uni.showLoading({
					title:'请求中'
				})
				uni.request({
					url: '/trade/getReturnBill',
					data: {
						account_no: this.account_no,
						original_serialno: this.serial_no
					},
					success: (res) => {
						if(res.data.success) {
							// this.trade_info = res.data.data
						} else {
							uni.showToast({
								icon: 'error',
								title: res.data.errMessage
							})
						}
					},
					complete: () => {
						uni.hideLoading()
					}
				})
			}
		}
	}
</script>

<style>
</style>